package com.se.domain.dto.wx;

import cn.hutool.json.JSONObject;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class WxAccessTokenDTO {
	private String accessToken;
	private Long expiresIn;
	private Long expiresTime;
	
	public WxAccessTokenDTO(JSONObject jsonObject) {
		this.accessToken = jsonObject.getStr("access_token");
		this.expiresIn = jsonObject.getLong("expires_in");
		//超时时间，expiresIn单位为秒，再减去一定误差时间，记为5分钟
		this.expiresTime = System.currentTimeMillis() + this.expiresIn * 1000 - 1000 * 60 * 5;
	}
}
